package com.neusoft.SPNursingHome.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neusoft.SPNursingHome.po.CheckOutRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

public interface CheckOutRecordDao extends BaseMapper<CheckOutRecord> {
    @Select("<script>" +
            "SELECT cor.*, c.client_name " +
            "FROM check_out_record cor " +
            "LEFT JOIN client c ON cor.client_id = c.client_id " +
            "<where> " +
            "    <if test='query.clientName != null and query.clientName != \"\"'> " +
            "        AND c.client_name LIKE CONCAT('%', #{query.clientName}, '%') " +
            "    </if> " +
            "    <if test='query.adId != null'> " +
            "        AND c.care_admin_id = #{query.adId} " +
            "    </if> " +
            "</where> " +
            "ORDER BY cor.check_out_id DESC" +
            "</script>")
    IPage<CheckOutRecord> findCheckOutRecordsPage(IPage<CheckOutRecord> page, @Param("query") Map<String, Object> query);
}



